package com.sky.wsp.job.util;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.concurrent.TimeUnit;

/**
 * @author wangshaopeng@talkweb.com.cn
 * @desccription 在此输入描述
 * @date 2023/8/14
 */
public class WebDriverUtil {
    private static WebDriver driver = null;
    // TODO 请改成你本地的驱动文件存放地址
    // 驱动下载地址：https://github.com/mozilla/geckodriver/releases
    private static String driverLocation = "C:\\Program Files (x86)\\Mozilla Firefox\\webdriver\\geckodriver-v0.16.1-win64\\geckodriver.exe";

    private static void setUp() {
        System.setProperty("webdriver.gecko.driver", driverLocation);
        driver = new ChromeDriver();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    public static WebDriver getDriver() {
        if (null == driver) {
            setUp();
        }
        return driver;
    }

    public static void driverQuit() {
        if (null == driver) {
            return;
        }
        driver.quit();
        driver = null;
    }


}
